package com.api.shopapi.mapper;

import com.api.shopapi.entity.NursingSchedulingNighttimeItem;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface NursingSchedulingNighttimeItemMapper {

    @Insert("insert  into nursing_scheduling_nighttime_item " +
            "(NursingSchedulingNighttimeItemCode,NursingSchedulingNighttimeCode,NurseCode,NurseName,NurseAideCode,NurseAideName) " +
            "values (#{nursingSchedulingNighttimeItem.NursingSchedulingNighttimeItemCode} ,#{nursingSchedulingNighttimeItem.NursingSchedulingNighttimeCode} ,#{nursingSchedulingNighttimeItem.NurseCode} ,#{nursingSchedulingNighttimeItem.NurseName} ,#{nursingSchedulingNighttimeItem.NurseAideCode} ,#{nursingSchedulingNighttimeItem.NurseAideName} )")
    int insert(@Param("nursingSchedulingNighttimeItem") NursingSchedulingNighttimeItem nursingSchedulingNighttimeItem);

    @Update("update nursing_scheduling_nighttime_item set NursingSchedulingNighttimeCode=#{nursingSchedulingNighttimeItem.NursingSchedulingNighttimeCode} ,NurseCode=#{nursingSchedulingNighttimeItem.NurseCode} ,NurseName=#{nursingSchedulingNighttimeItem.NurseName} ,NurseAideCode=#{nursingSchedulingNighttimeItem.NurseAideCode} ,NursingAideName=#{nursingSchedulingNighttimeItem.NurseAideName} where NursingSchedulingNighttimeItemCode=#{nursingSchedulingNighttimeItem.NursingSchedulingNighttimeItemCode}  ")
    int updateByNursingSchedulingNighttimeItemCode(@Param("nursingSchedulingNighttimeItem") NursingSchedulingNighttimeItem nursingSchedulingNighttimeItem);

    @Delete("delete from nursing_scheduling_nighttime_item where NursingSchedulingNighttimeItemCode=#{nursingSchedulingNighttimeItemCode} ")
    int deleteByNursingSchedulingNighttimeItemCode(@Param("nursingSchedulingNighttimeItemCode") String nursingSchedulingNighttimeItemCode);

    @Select("select * from nursing_scheduling_nighttime_item where NursingSchedulingNighttimeItemCode=#{nursingSchedulingNighttimeItemCode} limit 1")
    NursingSchedulingNighttimeItem getByNursingSchedulingNightTimeItemCode(@Param("nursingSchedulingNighttimeItemCode")String nursingSchedulingNighttimeItemCode);

    @Select("select * from nursing_scheduling_nighttime_item where NursingSchedulingNighttimeCode=#{nursingSchedulingNighttimeCode}")
    List<NursingSchedulingNighttimeItem> getListByNursingSchedulingNightTimeCode(@Param("nursingSchedulingNighttimeCode")String nursingSchedulingNighttimeCode);

    @Delete("delete from nursing_scheduling_nighttime_item where NursingSchedulingNighttimeCode=#{nursingSchedulingNighttimeCode} ")
    int deleteByNurseSchedulingNighttimeCode(@Param("nursingSchedulingNighttimeCode") String nursingSchedulingNighttimeCode);

    @Select("select * from nursing_scheduling_nighttime_item where NursingSchedulingNighttimeCode=#{nursingSchedulingNighttimeCode} and NurseAideCode=#{nurseAideCode} limit 1")
    NursingSchedulingNighttimeItem getByNursingSchedulingNightTimeCodeAndNurseAideCode(@Param("nursingSchedulingNighttimeCode") String nursingSchedulingNighttimeCode, @Param("nurseAideCode") String nurseAideCode);

    @Select("select * from nursing_scheduling_nighttime_item where NursingSchedulingNighttimeCode=#{nursingSchedulingNighttimeCode} and NurseCode=#{nurseCode} limit 1")
    NursingSchedulingNighttimeItem getByNursingSchedulingNightTimeCodeAndNurseCode(@Param("nursingSchedulingNighttimeCode") String nursingSchedulingNighttimeCode, @Param("nurseCode") String nurseCode);
}
